package cn.jinjimi.framework.plugin;

/**
 * Created by Hiro on 15/6/2.
 */
public class BasePlugin implements Plugin {

    /**
     * 插件名称
     */
    private String title;

    /**
     * 插件编码
     */
    private String code;

    /**
     * 插件源
     */
    private BasePluginConfig config;

    /**
     * 插件的权限,默认为0,即所有人可见
     */
    private PluginLimit limit = PluginLimit.EVERYONE;

    /**
     * 插件的来源 1.8.3添加
     */
    private String f_source;

    public BasePlugin(String title, String code, PluginLimit limit){
        this.title = title;
        this.code = code;
        this.limit = limit;
    }

    public BasePlugin(String title, String code){
        this.title = title;
        this.code = code;
    }

    public BasePlugin(String code){
        this.code = code;
    }

    public boolean equals(Object plugin){
        if(this==plugin)
            return true;

        if(plugin instanceof BasePlugin){
            BasePlugin p = (BasePlugin) plugin;
            if(p.code == this.code && p.title == this.title){
                return true;
            }
        }

        return false;
    }

    public BasePluginConfig getConfig() {
        return config;
    }

    public void setConfig(BasePluginConfig config) {
        this.config = config;
    }

    @Override
    public Class<? extends BasePlugin> getType() {
        return BasePlugin.class;
    }

    @Override
    public PluginLimit getLimit() {
        return limit;
    }

    public void setLimit(PluginLimit limit) {
        this.limit = limit;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCode() {
        return code;
    }


    public String getF_source() {
        return f_source;
    }

    public void setF_source(String f_source) {
        this.f_source = f_source;
    }
}
